package cn.iocoder.yudao.module.product.dal.mysql.stockinfo;


import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.product.dal.dataobject.stockinfo.StockInfoDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.product.controller.admin.stockinfo.vo.*;

import java.util.List;

/**
 * 库存信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface StockInfoMapper extends BaseMapperX<StockInfoDO> {

    default PageResult<StockInfoDO> selectPage(StockInfoPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<StockInfoDO>()
                .eqIfPresent(StockInfoDO::getOwnerType, reqVO.getOwnerType())
                .eqIfPresent(StockInfoDO::getOwnerId, reqVO.getOwnerId())
                .eqIfPresent(StockInfoDO::getSkuId, reqVO.getSkuId())
                .eqIfPresent(StockInfoDO::getSpuId, reqVO.getSpuId())
                .eqIfPresent(StockInfoDO::getSkuCount, reqVO.getSkuCount())
                .eqIfPresent(StockInfoDO::getVersion, reqVO.getVersion())
                .betweenIfPresent(StockInfoDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(StockInfoDO::getUpdater, reqVO.getUpdater())
                .orderByDesc(StockInfoDO::getId));
    }

    List<StockInfoSaveReqVO> selectBySkuProductType(StockInfoSaveReqVO respVO);
}